package demo.jvm;

import java.util.Arrays;

public class MyArrayList {
    private int[] table = new int[10];
    private int size = 0;

    public void add(int value) {
        if (size == table.length) {
            table = Arrays.copyOf(table, 2 * table.length);
        }
        table[size] = value;
        size++;
    }

    public int get(int index) {
        if (index > size || index < 0) {
            return -1;
        }
        return table[index];
    }

    public boolean isHuiWen(String str){
        return str.contentEquals(new StringBuffer(str).reverse());
    }

}
